﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CSharpDemo
{
    public partial class MainDemo : Form
    {
        public MainDemo()
        {
            InitializeComponent();
        }

        //创建对象。实例化对象
        DianChi changhong = null;
        private void btnChuangjian_Click(object sender, EventArgs e)
        {
            changhong = new DianChi();
            changhong.jiaGe = 10.0f;
            changhong.mingZi = "长虹电池";
            changhong.youXiaoQi = DateTime.Now;

            //MessageBox.Show("changhong的价格是:" + changhong.jiaGe);
            //MessageBox.Show("changhong的名字是:" + changhong.mingZi);
            //MessageBox.Show("changhong的有效期是:" + changhong.youXiaoQi.ToString());
            //MessageBox.Show(changhong.ToString());
        }

        private void btnCreatePhone_Click(object sender, EventArgs e)
        {
            //创建手机
            CellPhone nokia = new CellPhone();

            //设置数据
            nokia.brand = "诺基亚";
            nokia.name = "砸核桃专用机";
            nokia.price = 599;
            nokia.os = "Windows Phone 10";
            nokia.battery = changhong;
            //方法的调用：
            //nokia.AboutMe();
            nokia.PowerOn();//开机
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //设置电量
            changhong.dianLiang = 100;
        }
    }
}
